import cv2
import numpy as np


def add_image(src1, src2):
    dest = cv2.add(src1, src2)
    cv2.imshow('add', dest)


def subtract_image(src1, src2):
    dest = cv2.subtract(src1, src2)
    cv2.imshow('subtract', dest)


def multiply_image(src1, src2):
    dest = cv2.multiply(src1, src2)
    cv2.imshow('multiply', dest)


def divide_image(src1, src2):
    dest = cv2.divide(src1, src2)
    cv2.imshow('divide', dest)


def image_meanstddev(src1, src2):
    m1, dev1 = cv2.meanStdDev(src1)
    m2, dev2 = cv2.meanStdDev(src2)
    print(m1)
    print(dev1)

    print(m2)
    print(dev2)


def logic_demo(src1, src2):
    # dst = cv2.bitwise_and(src1, src2)
    # dst = cv2.bitwise_or(src1, src2)
    dst = cv2.bitwise_not(src2)
    cv2.imshow('and', dst)


def cons_bri_demo(img, c, b):
    h, w, ch = img.shape
    blank = np.zeros([h, w, ch], img.dtype)
    dst = cv2.addWeighted(img, c, blank, 1 - c, b)
    cv2.imshow('c-b-demo', dst)


windowslogo = cv2.imread('WindowsLogo.jpg', 1)
linuxlogo = cv2.imread('LinuxLogo.jpg', 1)
cv2.imshow('windowslog', windowslogo)
cv2.imshow('linuxlogo', linuxlogo)

# image_meanstddev(windowslogo, linuxlogo)
#
# add_image(windowslogo, linuxlogo)
# subtract_image(windowslogo, linuxlogo)
# multiply_image(windowslogo, linuxlogo)
# divide_image(windowslogo, linuxlogo)

# logic_demo(windowslogo, linuxlogo)
lena = cv2.imread('lena.jpg', 1)
cv2.imshow('origin', lena)
cons_bri_demo(lena, 1.1, 10)

cv2.waitKey(0)
cv2.destroyWindow('lena')
